function quickSort(arr){
    if(arr.length<=1)return arr
    let pivot=arr[0]
    let left=[],right=[]
    for(let i=1;i<arr.length;i++){
        if(arr[i]<=pivot){
            left.push(arr[i])
        }else{
            right.push(arr[i])
        }
    }
    return [...quickSort(left),pivot,...quickSort(right)]
}
let arr=[2,1,6,4,3,8,2]
console.log(quickSort(arr));